const app = getApp()
Component({
  data: {
    list: [{
        "icon": "smile-o",
        "text": "首页",
        "url": "/pages/home/home"
      },
      {
        "icon": "notes-o",
        "text": "医嘱",
        "url": "/pages/prescription/prescription"
      },
      {
        "icon": "like-o",
        "text": "药品",
        "url": "/pages/drugList/drugList"
      },
      {
        "icon": "info-o",
        "text": "关于",
        "url": "/pages/info/info"
      }
    ],
    active: 0
  },

  methods: {
    onChange(event) {
      this.setData({
        active: event.detail
      });
      wx.switchTab({
        url: this.data.list[event.detail].url
      });
    },

    init() {
      const page = getCurrentPages().pop();
      this.setData({
        active: this.data.list.findIndex(item => item.url === `/${page.route}`)
      });
    }
  }
})